class BootStrap {
 	 def init = { servletContext ->
        // Create some test data
			  new Podcast( feedURL:"http://feeds.grailspodcast.com/grailspodcast").save()
			  def b = new Bookmark(	url: new URL("http://www.google.com.ar"),
											title: "Google",
											dateCreated: new Date(),
											rating:8,
											type:'blog',
											notes: "--sin notas--").save()
				new Tag( bookmark: b,
								 name: "directory" ).save()
				new MenuItem( 	url:"http://localhost:9090/mallow",
												id:0,
												patherId:0,
												name: "/",
												description:"Root Mennu Item").save()

				def user_role  = new Role( authority: "ROLE_USER",
									description: "Default user role" ).save()
				def admin_role = new Role( authority: "ROLE_ADMIN",
									description: "Default admin role" ).save()
				def pm_role = new Role( authority: "ROLE_PM",
									description: "Default pm role" ).save()

				def user  = new User( email:"eleiva@gmail.com",
									passwd:"b1b3773a05c0ed0176787a4f1574ff0075f7521e",
									username:"eleiva",
									enabled:"true",
									description:"descr",
									userRealName:"Eduardo Leiva").save()			
	
				def user1  = new User( email:"enorton@gmail.com",
									passwd:"b1b3773a05c0ed0176787a4f1574ff0075f7521e",
									username:"enorton",
									enabled:"true",
									description:"descr",
									userRealName:"Edward Norton").save()			
	
				def user2  = new User( email:"pm@gmail.com",
									passwd:"b1b3773a05c0ed0176787a4f1574ff0075f7521e",
									username:"pm",
									enabled:"true",
									description:"descr",
									userRealName:"Project Manager").save()			

				def admin = new User( email:"admin@gmail.com",
									passwd:"b1b3773a05c0ed0176787a4f1574ff0075f7521e",
									username:"admin",
									enabled:"true",
									description:"Administrador de la aplicacion",
									userRealName:"Administrador ").save()			

				user_role.addToPeople(user)
				user_role.addToPeople(user1)
				pm_role.addToPeople(user2)

				admin_role.addToPeople(admin)

				def odra_customer = new Customer( name:"Odra",phone:"4211-0534",address:"La pampa 1488",createdBy:admin,dateCreated:new Date()).save()

				def mallow_project = new Project(name:"Mallow", customer:odra_customer,createdBy:admin,dateCreated:new Date()).save()

				def task1 = new Task( project:mallow_project,name:"Usuarios, Roles y Acegi",createdBy:admin,dateCreated:new Date()).save()
				def task2 = new Task( project:mallow_project,name:"Interfaz de usuario",createdBy:admin,dateCreated:new Date()).save()
				def task3 = new Task( project:mallow_project,name:"Correccin de Links",createdBy:admin,dateCreated:new Date()).save()
	
				new Issue(task:task1,type:"Todo",submitter:admin,assigned:user,description:"Configurar via Ldap",name:"Configurar via Ldap").save()
				new Issue(task:task1,type:"Todo",submitter:admin,assigned:user1,description:"Agregar acl",name:"Agregar acls").save()
				new Issue(task:task1,type:"Todo",submitter:admin,assigned:user,description:"Leer mucho mas de Acegi",name:"Leer Mas").save()
				new Issue(task:task2,type:"Todo",submitter:admin,assigned:user1,description:"Manejar mejor grails",name:"Templates en grails").save()
				new Issue(task:task3,type:"Todo",submitter:admin,assigned:user,description:"Correccion de links",name:"Corregir Links").save()
				
				new Requestmap(url: '/login/**', configAttribute: 'IS_AUTHENTICATED_ANONYMOUSLY').save()
				new Requestmap(url: '/logout/**', configAttribute: 'IS_AUTHENTICATED_ANONYMOUSLY').save()
				new Requestmap(url: '/captcha/**', configAttribute: 'IS_AUTHENTICATED_ANONYMOUSLY').save()
				new Requestmap(url: '/register/**', configAttribute: 'IS_AUTHENTICATED_ANONYMOUSLY').save()
				new Requestmap(url: '/css/**', configAttribute: 'IS_AUTHENTICATED_ANONYMOUSLY').save()
				new Requestmap(url: '/js/**', configAttribute: 'IS_AUTHENTICATED_ANONYMOUSLY').save()
				new Requestmap(url: '/images/**', configAttribute: 'IS_AUTHENTICATED_ANONYMOUSLY').save()
				new Requestmap(url: '/register/**', configAttribute: 'IS_AUTHENTICATED_ANONYMOUSLY').save()
				new Requestmap(url: '/user/**', configAttribute: 'ROLE_USER,ROLE_ADMIN').save()
				new Requestmap(url: '/task/**', configAttribute: 'ROLE_USER,ROLE_ADMIN').save()
				new Requestmap(url: '/issue/**', configAttribute: 'ROLE_USER,ROLE_ADMIN').save()
				new Requestmap(url: '/index**', configAttribute: 'ROLE_USER,ROLE_ADMIN').save()
				new Requestmap(url: '/project/**', configAttribute: 'ROLE_USER,ROLE_ADMIN').save()
	
				new Requestmap(url: '/requestmap/**', configAttribute: 'ROLE_ADMIN').save()
				new Requestmap(url: '/menuItem/**', configAttribute: 'ROLE_ADMIN').save()
				new Requestmap(url: '/role/**', configAttribute: 'ROLE_ADMIN').save()

				new Requestmap(url: '/**', configAttribute: 'IS_AUTHENTICATED_FULLY').save()
	//			new Requestmap(url: '/bookmark/list/**', configAttribute: 'IS_AUTHENTICATED_FULLY').save()
	//			new Requestmap(url: '/book/**', configAttribute: 'ROLE_SUPERVISOR').save()
				}
			
    def destroy = {
    }

} 
